//设置html根目录字体大小
require(['jquery','../modules/pageSize'],function($,pageSetSize){
    setRootFontSize(pageSetSize);
	var promotionList = [];
	var categoryList = [];
	var subnavList = [];
	var curShowPos = 0;
	var loadedList = [];
	// 渲染懒加载图片
	function renderImgs(pos){
		promotionList[pos].find("img").each(function(){
			if($(this).hasClass("img-lazyload")){
				$(this).attr("src", getDefaultImg($(this).attr("data-original")));
			}
		});
		categoryList[pos].find("img").each(function(){
			if($(this).hasClass("img-lazyload")){
				$(this).attr("src", getDefaultImg($(this).attr("data-original")));
			}
		});
	}
	$(".right-content .category-promote").each(function(i, o){		
		if(i == curShowPos){
			loadedList.push(true);
			$(this).css("display", "block");
		}else{
			loadedList.push(false);
			$(this).css("display", "none");	
		}
		promotionList.push($(this));
	});
	$(".right-content .category-list").each(function(i, o){
		if(i == curShowPos){
			$(this).css("display", "");
		}else{
			$(this).css("display", "none");	
		}
		categoryList.push($(this));
	});
	$(".left-menu a").each(function(i, o){
		if(i == curShowPos){
			$(this).addClass("active");
			renderImgs(i);
		}
		subnavList.push($(this));
		$(this).on("click", function(){
			if(i != curShowPos){
				if(!loadedList[i]){
					loadedList[i] = true;
					renderImgs(i);
				}
				subnavList[i].addClass("active");
				promotionList[i].css("display", "block");
				categoryList[i].css("display", "");
				subnavList[curShowPos].removeClass("active");
				promotionList[curShowPos].css("display", "none");
				categoryList[curShowPos].css("display", "none");
				curShowPos = i;				
			}
		});	
	});
    // 一级分类效果
    var winH = $(window).height();
    var topH = $('.category-bar').height();
    var botH = $('.fixed-main-menu').height();
	//console.log(winH-topH-botH);
    $('.left-menu,.right-box').css('height',winH-topH-botH);
});